﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Headers
{
    public class StyleAlignment:BaseElement
    {
        private HorizontalAlignment hAlignmentHorizontal;

        public HorizontalAlignment AlignmentHorizontal
        {
            get { return hAlignmentHorizontal; }
            set { hAlignmentHorizontal = value; }
        }
        private ulong? lIndent;

        public ulong? Indent
        {
            get { return lIndent; }
            set { lIndent = value; }
        }
        private ReadingOrder roTextReadingOrder;

        public ReadingOrder TextReadingOrder
        {
            get { return roTextReadingOrder; }
            set { roTextReadingOrder = value; }
        }
        private double? dRotate;

        public double? Rotate
        {
            get { return dRotate; }
            set { dRotate = value; }
        }
        private bool? bShrinkToFit;

        public bool? ShrinkToFit
        {
            get { return bShrinkToFit; }
            set { bShrinkToFit = value; }
        }
        private VerticalAlignment vAlignmentVertical;

        public VerticalAlignment AlignmentVertical
        {
            get { return vAlignmentVertical; }
            set { vAlignmentVertical = value; }
        }
        private bool? bVerticalText;

        public bool? VerticalText
        {
            get { return bVerticalText; }
            set { bVerticalText = value; }
        }
        private bool? bWrapText;

        public bool? WrapText
        {
            get { return bWrapText; }
            set { bWrapText = value; }
        }

        public StyleAlignment()
            : base(LocalNames.ALIGNMENT)
        {

        }
        public StyleAlignment(HorizontalAlignment halignment, 
            ulong lindent, ReadingOrder readingOrder, double drotate, 
            bool bshrinkTofit, VerticalAlignment valignment, bool verticaltext, 
            bool wraptext)
            : this()
        {
            this.hAlignmentHorizontal = halignment;
            this.lIndent = lindent;
            this.roTextReadingOrder = readingOrder;
            this.dRotate = drotate;
            this.bShrinkToFit = bshrinkTofit;
            this.vAlignmentVertical = valignment;
            this.bVerticalText = verticaltext;
            this.bWrapText = wraptext;
        }
        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            return dic;
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if(this.AlignmentHorizontal != null)
                dic.Add("Horizontal", Enum.GetName(typeof(HorizontalAlignment), this.AlignmentHorizontal));

            if(this.Indent != null)
                dic.Add("Indent", this.Indent.ToString());

            if(this.TextReadingOrder != null)
                dic.Add("ReadingOrder", Enum.GetName(typeof(ReadingOrder), this.TextReadingOrder));

            if(this.Rotate != null)
                dic.Add("Rotate",this.Rotate.ToString());

            if(this.ShrinkToFit != null)
                dic.Add("ShrinkToFit", this.ShrinkToFit.ToByte().ToString());

            if(this.AlignmentVertical != null)
                dic.Add("Vertical", Enum.GetName(typeof(VerticalAlignment), this.AlignmentVertical));

            if(this.VerticalText != null)
                dic.Add("VerticalText", VerticalText.ToByte().ToString());

            if(this.WrapText != null)
                dic.Add("WrapText", this.WrapText.ToByte().ToString());

            return dic;
        }

        protected override void SetDefaults()
        {
            return;
        }

        internal override string GetAttributeNamespace()
        {
            return Contstants.SpredsheetAttributePrefix;
        }

        internal override string GetAttributeNamespaceURI()
        {
            return Contstants.SpredsheetAttributeNamespace;
        }
    }
}
